<?php

namespace App\Http\Controllers\Web;

use App\Http\Controllers\Controller;
use App\Http\Resources\ServiceResource;
use App\Models\Service;
use Illuminate\Http\Request;

class ServiceController extends Controller
{
    public function index()
    {
        $resources = Service::select('*')
            ->latest('orderby')
            ->latest('id')
            ->paginate(request()->per_page ?? 10);

        return new ServiceResource($resources);
    }

    public function show(Service $service)
    {
        $service->increment('readnum');
        return $this->successful($service);
    }
}
